package com.glp.work.flow.constant;

import com.glp.common.enums.ReturnCode;

/**
 * @author liwenhong
 * @title 公共api code枚举
 * @date 2018/11/2.
 */
public enum  APICode implements ReturnCode {
  /** 200 - 999 系统公共错误码 */
  SUCCESS(200, "成功"),
  NOT_COMPLETE_QUOTA(504,"用信额度信息不全，请联系普洛斯"),
  AUTH_FAIL(401, "校验失败"),
  NO_PERMISSIONS(403, "无权限"),

  NOT_FOUND(404, "数据未找到"),

  NULL_PARAMETER(405, "参数为空"),
  INVALID_PARAMETER(406, "非法参数"),
  DATA_ALREADY_EXIST(407,"数据已存在"),
  DATA_INCONSIS_EXIST(408,"Excel文件和原有数据不一致"),

  ERROR(500, "服务端错误"),
  UNAVAILABLE(503, "服务不可用"),

  DATA_ERROR(550, "数据错误"),


  /** 1000 - 1999 账号*/
  AUTH_MISS_APPID(1000, "缺失参数APP KEY"),
  AUTH_FAIL_APPID(1001, "非法的APP KEY"),
  AUTH_EXPIRE(1010, "认证失效"),

  /** 2000 - 2999 权限*/
  MENU_CODE_EXISTS(2100, "菜单编码已存在"),

  /** 3000 - 3999 资金计划*/
  CASH_FUNDER_NOT_FOUND(3001,"找不到资金主体"),
  CASH_PLAN_PAY_DATE_FAIL(3002,"支付日期无效"),

  CASH_TYPE_NOT_FOUND(3101,"找不到资金类型"),
  CASH_FUNDER_DELETE_ERROR(3102,"该产品类型已被资金计划占用，不能删除该产品类型"),
  CASH_TYPE_DELETE_ERROR(3103,"该资金类型已被资金计划占用，不能删除该资金类型"),
  CASH_CURRENCY_DELETE_ERROR(3104,"该币种已被资金计划占用，不能删除该币种"),
  CASH_PAYMENT_DATE(3105, "不支持申请当月或者当月之前的资金计划"),
  CASH_PAYMENT_DATE_EFFECTIVE(3106, "支付日期已生效，无法删除"),


  /** 4000 - 4999 工作流*/
  /** 4001, "找不到流程" */
  WORKFLOW_PROCESS_NOT_FOUND(4001, "找不到流程"),
  /** 4101 剩余额度不足 */
  WORKFLOW_QUOTA_INSUFFICIENT(4101, "剩余额度不足"),
  /** 4901, "工作流节点处理错误" */
  WORKFLOW_COMPLETE_FAIL(4901, "节点处理错误"),
  /** 4902, "节点处理错误异常" */
  WORKFLOW_EXCEPTION(4902, "节点处理错误异常"),
  WORKFLOW_SUMBIT_FAIL(4903, "流程启动失败"),
  WORKFLOW_CHECK_DATA_FAIL(4904, "流程参数校验失败"),
  WORKFLOW_OCCUPY_FAIL(4905,"此数据已有流程存在")
  ;

  private int code;
  private String message;

  APICode(int code, String message) {
	this.code = code;
	this.message = message;
  }

  public static APICode fromCode(int code) {
	for(APICode api : values()) {
	  if(code == api.code) {
		return api;
	  }
	}
	return SUCCESS;
  }


  @Override
  public Integer getCode() {
    return code;
  }

  @Override
  public String getMessage() {
    return message;
  }
}
